const router = require('koa-router')()

const query = require('../db');

var uuid = require('uuid');

router.prefix('/menu');

router.get('/list', async (ctx, next) => {

    const { entryKey } = ctx.request.query;

    var sql = `select * from demo.menu`;

    let rows = await query(sql);

    ctx.body = {
        [entryKey]: rows
    }
})

router.get('/uuid', async (ctx, next) => {
    ctx.body = uuid.v1()
})

router.get('/json', async (ctx, next) => {
    ctx.body = {
        title: 'koa2 json'
    }
})

module.exports = router
